//
//  RequestTool.m
//  OAProject
//
//  Created by yhj on 2017/3/29.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "RequestTool.h"

@implementation RequestTool

+(instancetype)shareInstance
{
    static RequestTool *requestTool=nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        requestTool=[[RequestTool alloc]init];
    });
    return requestTool;
}

+(void)PostCallBack:(NSString *)url parameter:(NSDictionary *)dic success:(SuccessResult)success failure:(FailureResult)failure
{
    AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
    // 设置非校验证书模式
    manager.securityPolicy=[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
    // 是否允许无效证书（也就是自建的证书），默认为NO
    manager.securityPolicy.allowInvalidCertificates=YES;
    [manager.securityPolicy setValidatesDomainName:YES];

    [manager POST:url parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {

        success(responseObject);

    } failure:^(NSURLSessionDataTask *task, NSError *error) {

         failure(error);
    }];

}


@end
